﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Navigation;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor
{
    class FindTaskListTimeTagItem : FindTaskListItem
    {
        public FindTaskListTimeTagItem(string fileFullPath, string fileShortName, int lineNumber,
                                       int startLineOffset, int keywordLength, string lineText,
                                       Brush foreColor, ItemType type, TextDecorationCollection textDecorations = null) :
            base(fileFullPath, fileShortName, lineNumber, startLineOffset, keywordLength, lineText, foreColor, type, textDecorations)
        {
            DateTime dt;
            if (DateTime.TryParse(lineText.Substring(startLineOffset, keywordLength), out dt))
            {
                TagDateTime = dt;
            }
            else
            {
                TagDateTime = null;
                if (lineText.TrimStart().StartsWith("[@]"))
                {
                    TagHeader = "[@]";
                }
            }
        }

        public DateTime? TagDateTime { get; set; }

        public string TagHeader { get; set; } = null;
    }
}
